import java.util.ArrayList;
import java.util.Collection;


public class ProperActualParams2 {
	String fa;
	Expression exp;
	ProperActualParams2 pap2;
	int lineNum;
	int charPos;
	
	public ProperActualParams2 (String fa, Expression exp, ProperActualParams2 pap2, int line, int charP){
		this.fa = fa;
		this.exp = exp;
		this.pap2 = pap2;
		this.lineNum = line;
		this.charPos = charP;
	}
	public String toString(){
		String ret = "";

		String s = "";

		if (exp != null) {
			s +=  exp.toString();
		}
		if (pap2 != null) {
			s +=  pap2.toString();
		}
		
		return ret+s;
	}
	public void check(int x, String id) throws SemanticException {
		SymbolTable table = SymbolTable.getInstance();
		if (exp != null) {
			Collection<Entry> ce = table.st.values();
			ArrayList<Type> ls = new ArrayList<Type>();
			for(Entry e: ce)
				if(e.parent != null && e.parent.equals(id))
					ls.add(e.type);
			if(x >= ls.size())
				throw new SemanticException("Semantic Error at line " + this.lineNum + " char " + this.charPos + ":\nImproper method call.\nIn: " + Parser.getLineOfCode(this.lineNum));
			exp.check(ls.get(ls.size()-x-1));
		}
		if (pap2 != null) {
			pap2.check(x+1, id);
		}
	}
}
